//
//  LCVideoSingleListsCollectionView.m
//  JKFuYinProject
//
//  Created by admin on 2018/4/18.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LCVideoSingleListsCollectionView.h"
//#import "LSZTabbarVideoCollectionViewCell.h"
#import "LCVideoHomeListAboutModel.h"
#import "VideoCollectionViewCell.h"

@interface LCVideoSingleListsCollectionView ()
<UICollectionViewDelegate,UICollectionViewDataSource>


@end

@implementation LCVideoSingleListsCollectionView


- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{
    self = [super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        self.dataSource = self;
        self.delegate = self;
        self.backgroundColor = [UIColor whiteColor];
        [self registerClass:[VideoCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    }
    return self;
}

- (void)setModel:(LCRecommendHomeModel *)model{
    _model = model;
    NSLog(@"model.list = %zd", _model.list.count);
    [self reloadData];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _model.list.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    VideoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    LCVideoHomeListAboutModel *model = _model.list[indexPath.row];
    [cell.imageViewIcon sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    cell.titleLabel.text = [NSString stringWithFormat:@"%@",model.name];
    cell.backgroundColor = RGBColor(236, 236, 236);
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    LCVideoHomeModel *model = _model;
    LCVideoHomeListAboutModel *listAboutModel = model.list[indexPath.row];
    //点击方
    if (_pushBlock != nil) {
        _pushBlock(listAboutModel);
    }
}



@end
